<template>
  <div class="primarygradesort">
    <div class="primarygradesort-title" v-if="commodityType === 0">
      <div class="title-left">
        <div class="sekuai">
          <img v-if="datas.titlePic" draggable="false" :src="datas.titlePic" alt="" />
          <img v-else draggable="false" src="../../../assets/images/tit01.png" alt="" />
        </div>
        <!-- 标题 -->
        <h2
          v-if="datas.name"
          :style="{
            'font-size': datas.nameSize + 'px',
            'font-weight': datas.nameWeight,
            color: datas.nameColor,
            'text-align': datas.positions,
            'padding-right': !(datas.positions !== 'center') ? '0' : '10px',
          }">
          {{ datas.name }}
        </h2>
        <!-- 描述文字 -->
        <p
          v-if="datas.description"
          :style="{
            'font-size': datas.descriptionSize + 'px',
            'font-weight': datas.descriptionWeight,
            color: datas.descriptionColor,
            'text-align': datas.positions,
          }"
          style="margin-left: 8px">
          {{ datas.description }}
        </p>
      </div>
      <div class="title-right" v-show="datas.isShowRight">
        <span v-if="datas.rightText" style="margin-left: 5px">{{ datas.rightText }}</span>
        <div class="titrightpic">
          <img v-if="datas.rightPic" draggable="false" :src="datas.rightPic" alt="" />
          <img v-else draggable="false" src="../../../assets/images/playgreen.png" alt="" />
        </div>
      </div>
    </div>
    <div class="primarygradesort-title" v-if="commodityType === 1">
      <div class="title-left">
        <div class="sekuai">
          <img v-if="datas.titlePic" draggable="false" :src="datas.titlePic" alt="" />
          <img v-else draggable="false" src="../../../assets/images/tit02.png" alt="" />
        </div>
        <!-- 标题 -->
        <h2
          v-if="datas.name"
          :style="{
            'font-size': '16px',
            color: datas.nameColor,
            'text-align': datas.positions,
            'padding-right': !(datas.positions !== 'center') ? '0' : '10px',
          }">
          {{ datas.name }}
        </h2>
      </div>
      <div class="title-right" v-show="datas.isShowRight">
        <span v-if="datas.rightText" style="margin-left: 5px">{{ datas.rightText }}</span>
        <div class="titrightpic">
          <img v-if="datas.rightPic" draggable="false" :src="datas.rightPic" alt="" />
          <img v-else draggable="false" src="../../../assets/images/playgreen.png" alt="" />
        </div>
      </div>
    </div>
    <!-- 删除组件 -->
    <slot name="deles" />
  </div>
</template>

<script>
export default {
  name: "Primarygradesort",
  props: {
    datas: Object,
  },
  computed: {
    /* 类型切换 */
    commodityType() {
      return this.datas.commodityType;
    },
  },
};
</script>

<style scoped lang="scss">
.primarygradesort {
  border: 2px solid #fff;
  box-sizing: border-box;
  width: 100%;
  padding: 0 14px;
  min-height: 20px;
  position: relative;
  .primarygradesort-title {
    padding: 6px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    .title-left{
      display: flex;
      align-items: center;
      h2,
      p {
        word-wrap: break-word;
        min-height: 10px;
      }
      .sekuai {
        width: 24px;
        height: 24px;
        // background: linear-gradient(180deg, #77f37a 0%, #53c856 100%);
        // border-radius: 16px 16px 16px 16px;
        // display: block;
        margin-right: 6px;
        img {
          width: 100%;
        }
      }
    }
    .title-right{
      display: flex;
      align-items: center;
      .titrightpic{
        width: 16px;
        height: 16px;
        img{
          width: 100%;
        }
      }
      span{
        color:#666666;
        padding-right: 5px;
      }
    }
  }
}
</style>
